package com.yq.day20ye._02stringcahngge;

import java.util.logging.Level;

/**
 * @author 3307235355@qq.com
 * @since 2022/06/20 21:03
 */
public class Demo01 {
    public static void main(String[] args) {
        Student[] result = new Student[5];
        result[0] = new Student(12, 85.5);
        result[1] = new Student(23, 55.5);
        result[2] = new Student(22, 45.5);
        result[3] = new Student(15, 15.5);
        result[4] = new Student(17, 67.5);
        Object[] result2 = getResult(result, o -> ((Student) o).getAge());
        for (Object o : result2) {
            System.out.println(((Integer) o));
        }
    }

    public static Object[] getResult(Object[] o, Imp p) {
        Object[] result1 = new Object[o.length];
        int index = 0;
        for (Object o1 : o) {
            result1[index++]=p.convert(o1);
        }
        return result1;

    }
}


@FunctionalInterface
interface Imp {
    Object convert(Object o);
}

class Student {
    private int age;
    private double score;

    public Student(int age, double score) {
        this.age = age;
        this.score = score;
    }

    public int getAge() {
        return age;
    }

    public double getScore() {
        return score;
    }
}
